// Class
jsForms.Components.PhoneBookItems={
	Init:function(){
		return jsForms.Components.Component.Init.call(this);
	},
	Clear:function(){
		this.C.items.empty();
		return this;
	},
	Add:function(obj){
		var item = jsForms.CreateComponent('PhoneBookItem');
		item.SetPhone(obj.phone).SetName(obj.name);
		item.C.delete_action.bind('click',{parent:this,item:item},this.itemEventDelete );
		this.C.items.append(item);
		item.effect('highlight',500);
		return this;
	},
	itemEventDelete : function(e)
	{
		if (e.data.parent) {
			e.data.parent._ExecEvent('onDelete',e.data.item);
		}
		return this;
	},
	AddRange:function(arr){
		for(var i = 0; i < arr.length ;i++){
			var item = arr[i];
			this.Add(item);
		}
		return this;
	},
	Remove:function(item,noevent){
		item.remove();
		return this;
	}
};

jsForms.Components.PhoneBookItem={
	Init:function(){
		return jsForms.Components.Component.Init.call(this);
	},
	SetPhone:function(value)
	{
		this.C.phone[0].innerHTML = value;
		return this;
	},
	GetPhone:function()
	{
		return this.C.phone[0].innerHTML;
	},
	SetName:function(value)
	{
		this.C.name[0].innerHTML = value;
		return this;
	},
	GetName:function()
	{
		return this.C.name[0].innerHTML;
	}
};

// -----------------------------------------------
// Compilation INFO
// -----------------------------------------------
jsForms.CreateCompileInfoByObject(
{
	Name: 'PhoneBookItems',
	Events: {
		onDelete:{}
	}
});
